using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace GeoFramework.Examples
{
    public partial class CustomDeviceEmulatorForm : Form
    {
        public CustomDeviceEmulatorForm()
        {
            InitializeComponent();

            /* Check out the CustomEmulator class in the same directory as this
             * form to see how you can build your own emulators.  Emulated data
             * is parsed in exactly the same way as live data, by assigning an
             * NmeaInterpreter to a Stream which provides raw data.
             */

            CustomEmulatorInterpreter.BaseStream = new CustomEmulator();

            /* The interpreter is now started, and will process data generated
             * by your custom emulator.
             */

            CustomEmulatorInterpreter.Start();
        }

        private void CustomEmulatorInterpreter_SentenceReceived(object sender, GeoFramework.Gps.Nmea.NmeaSentenceEventArgs e)
        {
            // Add the newly-received sentence to the list box
            CustomSentencesListBox.Items.Add(e.Sentence.ToString());
            // Make sure the last item is always visible
            CustomSentencesListBox.SelectedIndex = CustomSentencesListBox.Items.Count - 1;
        }
    }
}